package com.huawei.struts.util;

import java.security.MessageDigest;

import sun.misc.BASE64Encoder;
/**
 * md5加密工具类
 * @author Administrator
 *
 */
public class EncryptUtil {
	/**
	 * DM5加密
	 * @param str
	 * @return
	 */
	public static String toMessageDigest(String str) {
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			BASE64Encoder encoder = new BASE64Encoder();
			return encoder.encode(md.digest(str.getBytes("utf-8")));
		} catch (Exception e) {
			throw new RuntimeException(e.getMessage());
		}

	}
	
}
